package main

import "fmt"

func main() {

	// map定义
	// 申明
	var mapVariable1 map[string]string
	// make
	mapVariable1 = make(map[string]string)
	mapVariable1["Monday"] = "12121"
	mapVariable1["turady"] = "1222121"
	fmt.Println(mapVariable1)

	// 长度
	fmt.Println(len(mapVariable1))

	// 申明的时候直接赋值
	var mapVariable2 = map[string]int{
		"Monday": 1, "Thusday": 2, "WednesDay": 3,
	}
	fmt.Println(mapVariable2)

	mapVariable3 := make(map[string]int)
	mapVariable3["mondy232323232"] = 4343
	fmt.Println(mapVariable3)

	// 切片 函数不能做为key

	mapVariable4 := map[int][]string{}

	var sliceVariable []string
	sliceVariable = make([]string, 2)
	sliceVariable[0] = "hahah"
	sliceVariable[1] = "world"
	mapVariable4[0] = sliceVariable
	fmt.Println(mapVariable4)

	// 只申明 会报错
	// map是引用类型

	//var mapVariable5 map[string]string
	//mapVariable5["hah"] = "hha"

	changeValue(mapVariable2)
	fmt.Println(mapVariable2)

	var sortKeys []string
	//sortKeys[0] = "22"
	sortKeys = append(sortKeys, "2")
	fmt.Println(sortKeys)

	for key := range mapVariable2 {
		sortKeys = append(sortKeys, key)
	}

	// 结构体 做为map的值
	type course struct {
	}
}

func changeValue(mapVarble map[string]int) {
	mapVarble["Monday"] = 100
}
